<?php
/**
 * Joomla! 1.5 component jhtraq
 *
 * @version $Id: view.html.php 2010-03-09 08:28:06 svn $
 * @author JHShop
 * @package Joomla
 * @subpackage jhtraq
 * @license GNU/GPL
 *
 * Traq type system for Joomla
 *
 * This component file was created using the Joomla Component Creator by Not Web Design
 * http://www.notwebdesign.com/joomla_component_creator/
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

// Import Joomla! libraries
jimport( 'joomla.application.component.view');
class JhtraqViewTickets extends JView {
    function display($tpl = null) {
//    $model =& JhtraqHelper::getModel('jhtraq');
//    print_r($model);

		$task = JRequest::getCmd('task', 'index');
		$tpl = $this->$task();
		
        parent::display($tpl);
    }
	
	function index()
	{
		$model =& JhtraqHelper::getModel('jhtraq');
		$this->types = $model->getTypes();
		$this->statuses = $model->getStatuses();
		$this->priorities = $model->getPriorities();
		$this->severities = $model->getSeverities();
	
	}
	
	function deleteType()
	{
		$id = JRequest::getVar('type');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->removeType($id);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Type Deleted'));
	}
	
	function saveTypes()
	{
		$data = JRequest::getVar('type');
		$name = JRequest::getVar('name','');
		$bullet = JRequest::getVar('bullet','');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->updateTypes($data,$name,$bullet);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Types Updated'));
	}
	
	function deleteStatus()
	{
		$id = JRequest::getVar('status');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->removeStatus($id);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Status Deleted'));
	}
	
	function saveStatuses()
	{
		//print_r($_POST);
		//die();
		$data = JRequest::getVar('statuses');
		$name = JRequest::getVar('name','');
		$status = JRequest::getVar('status','');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->updateStatuses($data,$name,$status);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Statuses Updated'));
	}
	
	function deletePriority()
	{
		$id = JRequest::getVar('priority');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->removePriority($id);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Priority Deleted'));
	}
	
	function savePriorities()
	{
		//print_r($_POST);
		//die();
		$data = JRequest::getVar('priorities');
		$name = JRequest::getVar('name','');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->updatePriorities($data,$name);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Priorities Updated'));
	}
	
	function deleteSeverity()
	{
		$id = JRequest::getVar('severity');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->removeSeverity($id);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Severity Deleted'));
	}
	
	function saveSeverities()
	{
		//print_r($_POST);
		//die();
		$data = JRequest::getVar('severities');
		$name = JRequest::getVar('name','');
		$model =& JhtraqHelper::getModel('jhtraq');
		$model->updateSeverities($data,$name);
		$mainframe = JFactory::getApplication();
		$mainframe->redirect("index.php?option=com_jhtraq&view=tickets",JText::_('Severities Updated'));
	}
	

	
	
}
?>